// pages/updateuserimg/updateuserimg.js
var util = require('../../utils/util.js')
Page({
  data: {
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
    var yid = options.id;
    var page = this;
    var data = {customerNo: yid}
    util.ajax("post", "/smallRoutineController/selectCustomertouserlist", data, function (res) {
      
      page.setData({ list: res.list[0]})
      console.log(res)
    })

  },
  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  },
  formSubmit: function (options) {
    
    var that = this;
    var customerNo = options.detail.value["list.customerNo"];
    var customerName = options.detail.value["list.customerName"];
    var customerSex = options.detail.value["list.customerSex"];
    var customerPhone = options.detail.value["list.customerPhone"];
    var communityName = options.detail.value["list.communityName"];
    var buildingName = options.detail.value["list.buildingName"];
    var data = { customerNo: customerNo, customerName: customerName, customerSex: customerSex,
      customerPhone: customerPhone, communityName: communityName, buildingName: buildingName }
    util.ajax("post", "/smallRoutineController/upCusetomertouser", data, function (res) {
      if (res.returnMsg.cookma == "200") {
        if (res.returnMsg.ynumber == "01") {
          console.log("更新数据成功")
          wx.redirectTo({
            url: '../../pages/newshowuser/newshowuser?ynumber=' + wx.getStorageSync("developer")//直接取值
          })
        }else{
          console.log("更新数据错误")
        }
        
              }else{
        console.log("出现异常")
      }
    })
  }
})